package learning.spring.helloworld.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 通过实现ApplicationListener接口监听ContextClosedEvent事件
 */
@Component
@Order(2)
public class ContextClosedEventListener implements ApplicationListener<ContextClosedEvent> {

    @Override
    public void onApplicationEvent(ContextClosedEvent event) {// 绑定了固定的事件，不如 @EventListener 灵活
        System.out.println("[ApplicationListener] ApplicationContext closed ");
    }

}
